<!doctype html>



  


<html class="theme-next pisces use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="jquery," />





  <link rel="alternate" href="/atom.xml" title="前端-洋洋" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.1" />






<meta name="description" content="这篇文章总结了一些个人的jquery小知识
回到顶部的按钮通过使用jQuery中的animate 与 scrollTop 方法可以创建一个非常简易的带有平滑滚动的回到顶部的按钮：1234567// Back to top$(&amp;apos;a.top&amp;apos;).click(function (e) &amp;#123;  e.preventDefault();  $(document.body).anim">
<meta property="og:type" content="article">
<meta property="og:title" content="一些jquery小技巧">
<meta property="og:url" content="http://html-js.site/2016/07/14/一些jquery小技巧/index.html">
<meta property="og:site_name" content="前端-洋洋">
<meta property="og:description" content="这篇文章总结了一些个人的jquery小知识
回到顶部的按钮通过使用jQuery中的animate 与 scrollTop 方法可以创建一个非常简易的带有平滑滚动的回到顶部的按钮：1234567// Back to top$(&amp;apos;a.top&amp;apos;).click(function (e) &amp;#123;  e.preventDefault();  $(document.body).anim">
<meta property="og:updated_time" content="2016-07-20T02:12:06.187Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="一些jquery小技巧">
<meta name="twitter:description" content="这篇文章总结了一些个人的jquery小知识
回到顶部的按钮通过使用jQuery中的animate 与 scrollTop 方法可以创建一个非常简易的带有平滑滚动的回到顶部的按钮：1234567// Back to top$(&amp;apos;a.top&amp;apos;).click(function (e) &amp;#123;  e.preventDefault();  $(document.body).anim">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 0,
      author: '博主'
    }
  };
</script>




  <link rel="canonical" href="http://html-js.site/2016/07/14/一些jquery小技巧/"/>

  <title> 一些jquery小技巧 | 前端-洋洋 </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  



  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?ca98d1db5559cb59848d14443c7fa5dd";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>








  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">前端-洋洋</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">专注于前端</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                一些jquery小技巧
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-07-14T16:27:08+08:00" content="2016-07-14">
              2016-07-14
            </time>
          </span>

          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2016/07/14/一些jquery小技巧/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/07/14/一些jquery小技巧/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>这篇文章总结了一些个人的jquery小知识</p>
<h3 id="回到顶部的按钮"><a href="#回到顶部的按钮" class="headerlink" title="回到顶部的按钮"></a>回到顶部的按钮</h3><p>通过使用jQuery中的<code>animate</code> 与 <code>scrollTop</code> 方法可以创建一个非常简易的带有平滑滚动的回到顶部的按钮：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">// Back to top</span><br><span class="line">$(&apos;a.top&apos;).click(function (e) &#123;</span><br><span class="line">  e.preventDefault();</span><br><span class="line">  $(document.body).animate(&#123;scrollTop: 0&#125;, 800);</span><br><span class="line">&#125;);</span><br><span class="line">&lt;!-- Create an anchor tag --&gt;</span><br><span class="line">&lt;a class=&quot;top&quot; href=&quot;#&quot;&gt;Back to top&lt;/a&gt;</span><br></pre></td></tr></table></figure></p>
<p>通过修改 <code>scrollTop</code>的值可以设置滚动最终停止的位置，最终的效果就是在800毫秒的时间内文档会被滚动到指定的地方。</p>
<h3 id="checkbox和radio的相关操作"><a href="#checkbox和radio的相关操作" class="headerlink" title="checkbox和radio的相关操作"></a>checkbox和radio的相关操作</h3><p>判断是否选中<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$(&apos;input.class&apos;).is(&apos;:checked&apos;);// true/false</span><br></pre></td></tr></table></figure></p>
<p>让某个选中,使用 <code>prop</code> 而不是 <code>attr</code><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$(&apos;input.class&apos;).prop(&apos;checked&apos;,true/false);</span><br></pre></td></tr></table></figure></p>
<p>取值<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$(&apos;input[name=name]:checked&apos;).val();</span><br></pre></td></tr></table></figure></p>
<h3 id="js-replaceAll实现"><a href="#js-replaceAll实现" class="headerlink" title="js replaceAll实现"></a>js replaceAll实现</h3><p><code>js</code> 没有 <code>java</code> 的 <code>replaceAll</code> 方法，这边有个方便的实现方法，利用正则<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">var aa = &apos;1212121212&apos;</span><br><span class="line">aa.replace(/1/g,&apos;2&apos;)</span><br><span class="line">//&quot;2222222222&quot;</span><br></pre></td></tr></table></figure></p>
<h3 id="检查图片是否加载完成"><a href="#检查图片是否加载完成" class="headerlink" title="检查图片是否加载完成"></a>检查图片是否加载完成</h3><p>有时候需要检查某个图片是否加载完成从而继续下面的操作：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">$(&apos;img&apos;).load(function () &#123;</span><br><span class="line">  console.log(&apos;image load successful&apos;);</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure></p>
<p>同样的，可以使用ID或者类选择器来判断某个特定的图片是否加载完成。</p>
<h3 id="图片加载失败的处理"><a href="#图片加载失败的处理" class="headerlink" title="图片加载失败的处理"></a>图片加载失败的处理</h3><p>在页面上如果发生某些图片加载失败是一个非常常见并且恶心的事情，如下的一小段代码可以在某种程度上解决这个问题：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">$(&apos;img&apos;).on(&apos;error&apos;, function () &#123;</span><br><span class="line">  $(this).prop(&apos;src&apos;, &apos;img/broken.png&apos;);</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure></p>
<p>即使没有发现任何的坏链的情况，也是建议将这段代码添加到页面中。</p>
<h3 id="使用Toggle"><a href="#使用Toggle" class="headerlink" title="使用Toggle"></a>使用Toggle</h3><p>很多时候需要的响应是在用户悬浮在某个元素上时改变其的可见性或者状态，换言之，即是在用户将鼠标悬浮在某个元素上时修改其的类属性，而在用户停止悬浮时移除该类:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">$(&apos;.btn&apos;).hover(function () &#123;</span><br><span class="line">  $(this).addClass(&apos;hover&apos;);</span><br><span class="line">  &#125;, function () &#123;</span><br><span class="line">    $(this).removeClass(&apos;hover&apos;);</span><br><span class="line">  &#125;);</span><br></pre></td></tr></table></figure></p>
<p>当然，更简单的就是利用 <code>toggleClass</code> 方法:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">$(&apos;.btn&apos;).hover(function () &#123;</span><br><span class="line">  $(this).toggleClass(&apos;hover&apos;);</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure></p>
<p><b>Note</b>: CSS的hover伪类可能是更方便的做法，不过知晓这种用法也是值得的。</p>
<h3 id="禁用输入框"><a href="#禁用输入框" class="headerlink" title="禁用输入框"></a>禁用输入框</h3><p>很多情况下我们希望提交按钮能够在部分文本框未填入的情况下处于禁用状态直到用户执行了某个动作，此时我们就需要为这个按钮添加disabled属性：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$(&apos;input[type=&quot;submit&quot;]&apos;).prop(&apos;disabled&apos;, true);</span><br></pre></td></tr></table></figure></p>
<p>如果需要回复输入框的状态，那么就要再次使用 <code>prop</code>方法, 不过将 <code>disabled</code> 的值设置为<code>false</code>:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$(&apos;input[type=&quot;submit&quot;]&apos;).prop(&apos;disabled&apos;, false);</span><br></pre></td></tr></table></figure></p>
<h3 id="阻止链接的加载"><a href="#阻止链接的加载" class="headerlink" title="阻止链接的加载"></a>阻止链接的加载</h3><p>有时候你不希望用户在点击了某个链接之后跳转到新的页面或者重载当前页面：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">$(&apos;a.no-link&apos;).click(function (e) &#123;</span><br><span class="line">  e.preventDefault();</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure></p>
<p>或者<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;a href=&quot;javascript:;&quot;&gt;&lt;/a&gt;</span><br></pre></td></tr></table></figure></p>
<h3 id="触发渐隐-滑动"><a href="#触发渐隐-滑动" class="headerlink" title="触发渐隐/滑动"></a>触发渐隐/滑动</h3><p>滑动与渐隐是jQuery种最常见的动画之一，很多时候我们希望能在用户点击某个元素之后将其渐隐渐出或者滑动出现：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">// Fade</span><br><span class="line">$(&apos;.btn&apos;).click(function () &#123;</span><br><span class="line">  $(&apos;.element&apos;).fadeToggle(&apos;slow&apos;);</span><br><span class="line">&#125;);</span><br><span class="line">// Toggle</span><br><span class="line">$(&apos;.btn&apos;).click(function () &#123;</span><br><span class="line">  $(&apos;.element&apos;).slideToggle(&apos;slow&apos;);</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>
<h3 id="将两个DIV设置为统一高度"><a href="#将两个DIV设置为统一高度" class="headerlink" title="将两个DIV设置为统一高度"></a>将两个DIV设置为统一高度</h3><p>有时候希望无论两个DIV种包含怎样的内容都能保持统一高度：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$(&apos;.div&apos;).css(&apos;min-height&apos;, $(&apos;.main-div&apos;).height());</span><br></pre></td></tr></table></figure></p>
<h3 id="根据文本选择元素"><a href="#根据文本选择元素" class="headerlink" title="根据文本选择元素"></a>根据文本选择元素</h3><p>通过使用 <code>contains()</code> 选择器可以根据内容搜索对应的元素，下述代码的作用就是在文本不存在的时候隐藏元素：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">var search = $(&apos;#search&apos;).val();</span><br><span class="line">$(&apos;div:not(:contains(&quot;&apos;+search+&apos;&quot;))&apos;).hide();</span><br></pre></td></tr></table></figure></p>
<h3 id="可见性变化时候的触发"><a href="#可见性变化时候的触发" class="headerlink" title="可见性变化时候的触发"></a>可见性变化时候的触发</h3><p>在某个Tab获得焦点或者失去焦点的时候：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">$(document).on(&apos;visibilitychange&apos;, function(e)&#123;</span><br><span class="line">  if (e.target.visibilityState === &quot;visible&quot;) &#123;</span><br><span class="line">    console.log(&apos;Tab is now in view!&apos;);</span><br><span class="line">  &#125; else if (e.target.visibilityState === &quot;hidden&quot;) &#123;</span><br><span class="line">    console.log(&apos;Tab is now hidden!&apos;);</span><br><span class="line">  &#125;</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure></p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        
  <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
    <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
    <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
      <span>赏</span>
    </button>
    <div id="QR" style="display: none;">
      
        <div id="wechat" style="display: inline-block">
          <img id="wechat_qr" src="/wechat.jpg" alt="wangyang WeChat Pay"/>
          <p>微信打赏</p>
        </div>
      
      
        <div id="alipay" style="display: inline-block">
          <img id="alipay_qr" src="/alipay.jpg" alt="wangyang Alipay"/>
          <p>支付宝打赏</p>
        </div>
      
    </div>
  </div>


      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/jquery/" rel="tag">#jquery</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2016/07/05/JavaScript中创建对象的模式汇总/" rel="next" title="JavaScript中创建对象的模式汇总">
                <i class="fa fa-chevron-left"></i> JavaScript中创建对象的模式汇总
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2016/08/18/如何优雅地使用Sublime Text/" rel="prev" title="工欲善其事必先利其器-sublimetext使用技巧">
                工欲善其事必先利其器-sublimetext使用技巧 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2016/07/14/一些jquery小技巧/"
           data-title="一些jquery小技巧" data-url="http://html-js.site/2016/07/14/一些jquery小技巧/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/default_avatar.jpg"
               alt="wangyang" />
          <p class="site-author-name" itemprop="name">wangyang</p>
          <p class="site-description motion-element" itemprop="description">专注于前端</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">15</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">23</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/WangYang-Rex" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://weibo.com/u/2690568063/" target="_blank" title="Weibo">
                  
                    <i class="fa fa-fw fa-weibo"></i>
                  
                  Weibo
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="617418875" target="_blank" title="QQ">
                  
                    <i class="fa fa-fw fa-qq"></i>
                  
                  QQ
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="mailto:617418875@qq.com" target="_blank" title="Mail">
                  
                    <i class="fa fa-fw fa-envelope-o"></i>
                  
                  Mail
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              友链
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://http://moshui.site/" title="moxhuis" target="_blank">moxhuis</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://indexof.site/" title="indexof" target="_blank">indexof</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://xiaoqiang730730.github.io/" title="xiaoqiang" target="_blank">xiaoqiang</a>
                </li>
              
            </ul>
          </div>
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#回到顶部的按钮"><span class="nav-number">1.</span> <span class="nav-text">回到顶部的按钮</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#checkbox和radio的相关操作"><span class="nav-number">2.</span> <span class="nav-text">checkbox和radio的相关操作</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#js-replaceAll实现"><span class="nav-number">3.</span> <span class="nav-text">js replaceAll实现</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#检查图片是否加载完成"><span class="nav-number">4.</span> <span class="nav-text">检查图片是否加载完成</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#图片加载失败的处理"><span class="nav-number">5.</span> <span class="nav-text">图片加载失败的处理</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#使用Toggle"><span class="nav-number">6.</span> <span class="nav-text">使用Toggle</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#禁用输入框"><span class="nav-number">7.</span> <span class="nav-text">禁用输入框</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#阻止链接的加载"><span class="nav-number">8.</span> <span class="nav-text">阻止链接的加载</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#触发渐隐-滑动"><span class="nav-number">9.</span> <span class="nav-text">触发渐隐/滑动</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#将两个DIV设置为统一高度"><span class="nav-number">10.</span> <span class="nav-text">将两个DIV设置为统一高度</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#根据文本选择元素"><span class="nav-number">11.</span> <span class="nav-text">根据文本选择元素</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#可见性变化时候的触发"><span class="nav-number">12.</span> <span class="nav-text">可见性变化时候的触发</span></a></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">wangyang</span>
</div>

<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>

        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.1"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.0.1"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.1"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"html-js"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
    <script src="/vendors/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  






  
  

  

  

  

</body>
</html>
